#include <bits/stdc++.h>
using namespace std;
int n, l, r, last, t, x, y;
int a[100006];
int main()
{
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] == 2)
            y++;
        else if (a[i] == 1)
            x++;
    }
    sort(a + 1, a + n + 1);
    if (a[1] == a[n])
    {
        cout << n;
        return 0;
    }
    if (a[1] == 1 && a[n] == 2)
    {
        if (x < y)
            cout << y;
        else if (x >= y)
            cout << x;
        return 0;
    }
    last = 1;
    while (r <= n)
    {
        l = last;
        r = l + 1;
        while (a[r] <= a[l] && r <= n)
            r++;
        t = a[r];
        while (a[l] == last && a[r] == t)
            l++, r++;
        last = l;
    }
    cout << n - l + 1;
    return 0;
}
